<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="DBController.*" %>
<%@ page import="java.util.List" %>

<%
	HttpSession hostsession = request.getSession(true);
int hostUserID = Integer.parseInt(hostsession.getAttribute("hostUserID").toString());
DBConnector dbConn = DBConnector.getInstance();
int cityID = Integer.parseInt(request.getParameter("cityID"));
int clickNumber = Integer.parseInt(request.getParameter("clickNumber"));
List<city> cityList = dbConn.getCities();
//List<district> districtList = dbConn.getDistricts(cityID);
DBController.hostFamily hostfamilyObj = dbConn.getHostFamilyByUserID(hostUserID);
int hostCityID = dbConn.getCityIDByDistrictID(hostfamilyObj.getDistrictID());
List<district> districtList = new ArrayList<district>();
System.out.println(hostfamilyObj.getHostFamilyID());
if(hostfamilyObj.getHostFamilyID()==0 || clickNumber > 0){
	districtList = dbConn.getDistricts(cityID);
}
else{
	districtList = dbConn.getDistricts(hostCityID);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<div id="cities">
<label>City</label>
<select id="city" name="city">
<%for(city cityObj : cityList){%>
<option value="<%=cityObj.getCityID()%>"<%if(cityObj.getCityID()==hostCityID){%>selected<%} %>><%=cityObj.getCityName()%></option>
<%}%>
</select>
</div>
<div id="districts">
<label>District</label>
<select name="district">
<%for(district districtObj : districtList){%>
<option value="<%=districtObj.getDistrictID()%>" <%if(districtObj.getDistrictID()==hostfamilyObj.getDistrictID()){%>selected<%} %>><%=districtObj.getDistrictName()%></option>
<%}%>
</select>
</div>
<div id="publicTransportDistance"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getPublicTransportDistance()%><%} %></div>
<div id="minStayDay"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getMinStayDay()%><%} %></div>
<div id="maxStayDay"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getMaxStayDay()%><%} %></div>
<div id="numberOfAdult"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getNumberOfAdult()%><%} %></div>
<div id="numberOfChildren"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getNumberOfChildren()%><%} %></div>
<div id="isSmokingAllowed"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getIsSmokingAllowed()%><%} %></div>
<div id="isMealProvided"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getIsMealProvided()%><%} %></div>
<div id="pricePerMeal"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getPricePerMeal()%><%} %></div>
<div id="isPetHeld"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getIsPetHeld()%><%} %></div>
<div id="isInternetProvided"><%if(hostfamilyObj.getHostFamilyID()>0){%><%=hostfamilyObj.getIsInternetProvided()%><%} %></div>
</body>
</html>